<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function Person(name, age) {
        this.name = name
        this.age = age
    }

    Person.prototype.sayName = function () {
        console.log(this.name)
    }

    let p = new Person('zhangsan')
    console.log(p);

    function new2(constructor, ...arg) {
        const obj = Object.create(null)
        Object.setPrototypeOf(obj, constructor.prototype)
        constructor.apply(obj, arg)
        return obj
    }

    let p2 = new2(Person, 'zhangsan', 18)
    console.log(p2);
</script>
</body>
</html>
